/*
 * Copyright 2018-10-1 20:47:06 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.erp.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.admin.support.MybatisBatch;
import com.lap.scp.erp.core.PaymentManager;
import com.lap.scp.erp.dal.PaymentDAO;
import com.lap.scp.erp.domain.ArtificialDO;
import com.lap.scp.erp.domain.PaymentDO;
import com.lap.scp.erp.query.PaymentQueryVO;

/**
 * <pre>
 * 其他成本业务代码默认实现类，这里提供最小元素原子操作，所以尽量少在该类中做流程代码。
 * 业务流程代码应该写在AO中。
 * </pre>
 * 
 * @author 劳水生 Exp
 * @Date 2018-10-1 20:47:06
 * @since 2.0.0
 */
@Service("paymentManager")
public class DefaultPaymentManager implements PaymentManager {
	/**
	 * 其他成本数据操作对象
	 */
	@Resource
	private PaymentDAO paymentDAO;

	@Resource
	private MybatisBatch mybatisBatch;

	@Override
	public void insertPayment(PaymentDO paymentDO) throws ManagerException {
		paymentDAO.insertPayment(paymentDO);
	}

	@Override
	public void insertPaymentBatch(List<PaymentDO> list) throws ManagerException {
		mybatisBatch.insertBatch("com.lap.scp.erp.dal.PaymentDAO.insertPayment", list);
	}

	@Override
	public int deleteById(Integer paymentId) throws ManagerException {
		return paymentDAO.deleteById(paymentId);
	}

	@Override
	public PaymentDO queryById(Integer paymentId) throws ManagerException {
		return paymentDAO.queryById(paymentId);
	}

	@Override
	public List<PaymentDO> queryDetail(PaymentQueryVO queryVO) throws ManagerException {
		return paymentDAO.queryDetail(queryVO);
	}

	@Override
	public List<ArtificialDO> querySalaryPage(Page page, PaymentQueryVO queryVO) throws ManagerException {
		int count = paymentDAO.countSalaryPage(queryVO);
		if (count == 0) {
			return Collections.emptyList();
		} else {
			page.setTotalItem(count);
			return paymentDAO.querySalaryPage(page, queryVO);
		}
	}

	@Override
	public int updatePayment(PaymentDO paymentDO) throws ManagerException {
		return paymentDAO.updatePayment(paymentDO);
	}

}
